<template>
  <div id="page">
    <div class="top_box">
      <img v-src="'/static/img/my/applyTop.png'" alt="">
    </div>
    <div class="container">
      <p>手机号:</p>
      <p>
        <input v-model="phoneNumber" type="number" placeholder="请输入手机号" >
      </p>
      <p>
        <input v-model="yanzhengma" type="number" placeholder="短信验证码">
        <button @click="getyzm" class="getBtn flex-grow-0 flex-y-center">点击获取</button>
      </p>
      <p>提现支付宝账号</p>
      <p>
        <input v-model="zfbName" type="text" placeholder="支付宝名称">
      </p>
      <p style="margin-top: 0.3rem">
        <input v-model="zfbAccount" type="number" placeholder="支付宝账号">
      </p>
      <div @click="applyClick"  class=" btnBox flex-grow-0 flex-y-center flex-x-center" :class="{'current':userStatus==2}">
        <span v-show="userStatus==1">申&nbsp;请</span>
        <span v-show="userStatus==2">审核中</span>
        <span v-show="userStatus==3">完成</span>
      </div>
    </div>
    <div v-show="userStatus==2" class="mask">
      <div  class="text">
        <p>人工正在审核 &nbsp;&nbsp;我们会尽快提审</p>
         <p>请您耐心等待</p>
      </div>
      <div class="loading-dedai">
        <div class="bounce1"></div>
        <div class="bounce2"></div>
        <div class="bounce3"></div>
      </div>
    </div>
    <div v-show="userStatus==3" class="mask ">
      <div  class="text">
        <p>恭喜您!&nbsp;已经成为合伙人</p>
        <p>请点击下方—完成</p>
      </div>
    </div>
    <!--<div class="message">-->
      <!--提交成功 <br>正在审核中……-->
    <!--</div>-->
    <!--<div class="message">-->
      <!--您已经是合伙人-->
    <!--</div>-->
  </div>
</template>
<script>
  import {APPLYPARTNER,GETUSERINFO,GETCODEREGISTER} from 'src/const/uri'
  export default{
    data(){
      return {
        phoneNumber:'',
        yanzhengma:'',
        zfbName:'',
        zfbAccount:'',
        userStatus:''
      }
    },
    created(){

    },
    watch:{
      phoneNumber(val){

      }
    },
    mounted(){
      let spinner = document.getElementsByClassName('spinner')[0];
      spinner.style.display = 'none';
      this.getUserInfo();
    },
    methods:{
      getUserInfo(){
        this.$ajax.get(GETUSERINFO,{},(res)=>{
          console.log(res)
          this.phoneNumber=res.data.userName;
          this.userStatus=res.data.parnterStatus;
        });
      },
      refreshData(responseCallback) {
        this.getUserInfo();
        responseCallback({code: '0'});
      },
      getyzm(){
        if(this.phoneNumber){
          this.$ajax.post(GETCODEREGISTER,{
            phone:this.phoneNumber,
            useVerifyCode:2
          },(res)=>{
            this.$vux.toast.show({type: 'text', text: `${res.message}`});
          })
        }
      },
      applyClick(){
        if(this.userStatus==1){
          if(this.phoneNumber && this.yanzhengma && this.zfbName && this.zfbAccount){
            this.$ajax.post(APPLYPARTNER,{
              captcha:this.yanzhengma, //shouji yanzheng ma
              zfbName:this.zfbName,
              zfbAccount:this.zfbAccount
            },(res)=>{
              console.log(res)
              if(res.data=="OK"){
                this.getUserInfo();
              }
            });
          }else{
            this.$vux.toast.show({  type:'warn',
              text:'不能为空'}
            )
          }
        }else if(this.userStatus==3){
          let beforeUrl = document.URL.replace(/applyPartner/g, "description").split('?')[0];
          // if (window.WebViewJavascriptBridge) {
          //   window.WebViewJavascriptBridge.callHandler('jumpTo', beforeUrl);
          // } else if (isDebug) {
            window.location.href = beforeUrl;
          }
        // }
      }
    }
  }
</script>
<style lang="less" scoped>
  @import "index";
</style>
